package com.fh.modules.ems.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fh.modules.ems.entity.EmsCouponTemplateProductCategoryRel;
import com.fh.modules.ems.entity.EmsCouponTemplateProductRel;
import com.fh.modules.ems.mapper.EmsCouponTemplateProductRelMapper;
import com.fh.modules.ems.service.IEmsCouponTemplateProductRelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fh.common.web.impl.AbstractServiceImpl;

/**
 * @Description: 优惠券模板和产品关系
 * @author： code generator
 * @date：   2019-09-26
 * @version： V1.0
 */
@Service
public class EmsCouponTemplateProductRelServiceImpl extends AbstractServiceImpl<EmsCouponTemplateProductRelMapper, EmsCouponTemplateProductRel> implements IEmsCouponTemplateProductRelService {

    @Autowired
    private EmsCouponTemplateProductRelMapper emsCouponTemplateProductRelMapper;

    @Override
    public boolean validateProductCouponTemplateRel(Integer productId, Integer couponTemplateId) {
        LambdaQueryWrapper<EmsCouponTemplateProductRel> query=new LambdaQueryWrapper<>();
        query.eq(EmsCouponTemplateProductRel::getCouponTemplateId,couponTemplateId);
        query.eq(EmsCouponTemplateProductRel::getProductId,productId);
        return this.count(query)>0;
    }
}
